package com.example.forjava.task;

import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class InvokeService {

    Map<String, ITask> serviceMap = new HashMap<>();


    public InvokeService(List<ITask> tasks) {
        tasks.forEach(s-> serviceMap.put(s.type(), s));
    }

    public void invoke(String type) {
        serviceMap.get(type).invoke();
    }


}
